package com.zzty.zzlp.serviceimpl;

import com.zzty.zzlp.dao.ClazzMapper;
import com.zzty.zzlp.entity.Clazz;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zzty.zzlp.service.ClazzService;

import java.util.List;

@Service
public class ClazzServiceImpl implements ClazzService {
    @Autowired
    ClazzMapper clazzMapper;

    @Override
    public JSONArray searchAllClazzName() {
        JSONArray jsonarray = new JSONArray();
        List<Clazz> clazz = clazzMapper.getAllClazz();
        for (int i = 0; i < clazz.size(); i++) {
            JSONObject jsonobject = new JSONObject();
            jsonobject.put("clazzId", clazz.get(i).getId());
            jsonobject.put("clazzName", clazz.get(i).getName());
            jsonarray.add(jsonobject);
        }
        return jsonarray;
    }

    @Override
    public List<Clazz> getAllClazz() {

        return clazzMapper.getAllClazz();
    }
}
